import Book.BookList;
import User.*;


import java.util.Scanner;

/**
 * @Author YuanYuan
 * @Date 2022/5/18
 * @Time 10:55
 */
public class Test {

    public static User alMenu() {
        System.out.println("欢迎来到图书管理系统！");
        System.out.println("请输入您的名字：");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        System.out.println("请输入身份：1 -> 图书管理员  2 -> 普通用户");
        int indentity = scanner.nextInt();
        scanner.nextLine();
        if(1 == indentity) {
            int frequency = 3;
            while (frequency > 0) {
                System.out.print("请输入密码:");
                String mycode = scanner.nextLine();
                if(mycode.equals(AdminUser.code)) {
                    break;
                }
                frequency --;
                if(frequency == 0) {
                    System.out.println("退出程序！");
                    return null;
                }
                System.out.println("输入错误！您还有"+frequency+"次机会！");
            }
            return new AdminUser(name);

        }else if(2 == indentity) {
            return new NormalUser(name);
        }
        return null;
    }

    public static void main(String[] args) {
        BookList bookList = new BookList();
        User user = alMenu();
        if(null == user){
            System.exit(0);
        }
        while (true) {
            int score = user.menu();
            user.inplementInterface(score,bookList);
        }


    }

}
